/**
 * Created by win10 on 2019/4/30.
 */
var client = require('./../../util/redis_init');
var gameConfig = require("./../config/gameConfig");
var log = require("./../../util/loginfo").getInstand;

client.on("error", function (err) {
    //log.info("RedisError :", err);
});

client.on('connect', function () {
    //log.info('Redis连接成功.');
})


//
// //获得重置下注数组
// exports.init_bet_list = function init_bet_list() {
//     //清除数组
//     client.del(redis_bet_list_key);
//
// };

//保存聊天记录
exports.save_club_chat = function save_club_chat(redis_key, _info) {

    return new Promise((resolve, reject) => {
        client.rpush(redis_key, _info);
        client.ltrim(redis_key, -30, -1);
        resolve(_info)
    })



};


//获取俱乐部聊天记录
exports.get_club_chat_record = function get_club_chat_record(redis_key) {
    return new Promise((resolve, reject) => {
        client.lrange(redis_key, 0., -1, function (err, lists) {
            // //log.info('get_club_chat_record: err :lists: ', err, lists);
            var result = [];
            if (!err) {
                for (var i in lists) {
                    result.push(JSON.parse(lists[i]))
                }
                resolve(result)
            }

        })
    })


};




